﻿using PluginAPI.Core;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using RoleCustom.Event;



namespace RoleCustom.Main
{
    internal class CodeLoad
    {
        public static CodeLoad Singleton { get; set; }

        [PluginConfig] public Config Config;



        public ReferenceHub AudioHub { get; set; }
        public bool IsReadyContain { get; internal set; }
        public uint Current { get; set; }



        [PluginEntryPoint("06 角色设定", "v1.0.0", "角色设定", "River")]
        [PluginPriority(LoadPriority.Medium)]
        public void Load()
        {
            if (!this.Config.IsEnable) return;

            Singleton = this;

            Log.Info($"NWPluginAPI| 角色设定 | 加载");

            //Startup.SetupDependencies();

            EventManager.RegisterEvents<PlayerEvent>(true);
            EventManager.RegisterEvents<NTFSpawnEvent>(this.Config.NTFPrivateEvent.IsEnabled);
            EventManager.RegisterEvents<ScientistEvent>(this.Config.ScientistEvent.IsEnabled);
            EventManager.RegisterEvents<FacilityGuardEvent>(this.Config.FacilityGuardEvent.IsEnabled);
            EventManager.RegisterEvents<ClassDEvent>(this.Config.ClassDEvent.IsEnabled);
            EventManager.RegisterEvents<SCP049Event>(this.Config.SCP049Event.IsEnabled);
            EventManager.RegisterEvents<SCP173Event>(this.Config.SCP173Event.IsEnabled);
            EventManager.RegisterEvents<SCP3114Event>(this.Config.SCP3114Event.IsEnabled);
            EventManager.RegisterEvents<SCP106Event>(this.Config.SCP106Event.IsEnabled);
            EventManager.RegisterEvents<SCP096Event>(this.Config.SCP096Event.IsEnabled);
            EventManager.RegisterEvents<SCP939Event>(this.Config.SCP939Event.IsEnabled);
        }

        [PluginUnload]
        public void UnLoad()
        {
            Singleton = null;
            EventManager.UnregisterEvents(this);
        }
    }
}
